<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
		<title></title>
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" href="../../css/app.css">
		<style>
			body{#fff}
			.mui-bar-nav{background:#fff;color: #000;}
			.mui-bar-nav .mui-icon-left-nav{color:#000}
			.mui-bar-nav>.back{color:#000;margin-top: .04rem;}
			.mui-content{padding-top:0 !important;width: 100%;height: 100%;position: absolute;/*top: 0.9rem;*/left: 0;background: #fff;}
			.mui-content .title{text-align: center;position: relative;top: 0.3rem;font-size: 0.36rem;color: #333333;}
			.mui-content .input_box{width: 100%;height: 1.82rem;margin: 0;padding: 0;position: absolute;top: 1.66rem;}
			.mui-content .input_box li{width: 100%;height: 0.91rem;border-bottom: 1px solid #eeeeee;padding-left:1.4rem ;box-sizing: border-box;}
			.mui-content .input_box input{width: 100%;height: 100%;border: none;padding: 0;margin: 0;font-size:0.26rem;}
			.mui-content .input_box input::-webkit-input-placeholder {font-size:0.26rem;color: #cccccc;} 
			.mui-content .input_box li:first-child{background: url(../../images/menu/pwd.png) no-repeat center;background-position-x:0.75rem;background-size:0.25rem;}
			.mui-content .input_box li:last-child{background: url(../../images/menu/pwd.png) no-repeat center;background-position-x:0.75rem;background-size:0.25rem;}
			.mui-content .input_box li .keycode{width: 1.85rem !important;height: 0.58rem !important;font-size: 0.24rem !important;color: #fff !important;position: absolute !important;top: 1.06rem !important;right: 0.4rem !important;}
			/*.mui-content .info{color: #666666;width: 100%;height: 0.17rem;font-size: 0.18rem;position: absolute;top: 4.72rem;padding-left: 0.86rem;}*/
			.next{width: 6rem;height: 0.68rem;background: #117afd;font-size: 0.3rem;color: #fff;border: none;outline: none;position: absolute !important;top:5.31rem  !important;left: 0.75rem !important;border-radius: 0.1rem;}
		
			.mui-icon{right: 0.6rem !important;font-size: 0.45rem !important;}
			.mui-icon-clear{right: 1.4rem !important;}
		</style>
	</head>
	<body>
		<!--<div class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<a class="back">返回</a>
		</div>-->
		<div class="mui-content">
			<div class="title">设置密码</div>
			<ul class="input_box">
				<li class="mui-input-row">
					<input class="mui-input-password mui-input-clear" id="psd" type="password" placeholder="请输入密码"/>
				</li>
				<li class="mui-input-row">
					<input class="mui-input-password mui-input-clear" id="psdConf" type="password" placeholder="请再次输入密码" />
				</li>
			</ul>
			<!--<div class="info">注册即使为统一<a href="">《政务服务网用户注册协议》</a></div>-->
			<button class="next mui-btn mui-btn-primary">下一步</button>
		</div>
	
	</body>
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/common.js"></script>
	<script src="../../js/md5.min.js" ></script>
	<script src="../../js/app.js" ></script>
	<script>
		var phone = utils.getUrlParam('phone');
		document.querySelector('.next').addEventListener('tap',function(){
			var psd = document.getElementById('psd').value;
			var psdConf = document.getElementById('psdConf').value;
			if (!psdCheck(psd)) {
				return;
			}
			if (psd != psdConf) {
				mui.toast('两次密码不一致');
				return;
			}
			var param = {};
			param.phone = phone;
			param.psd = md5(psd);
			utils.ajax('appHttpService/appRegister.do',function(data){
				var data = JSON.parse(data);
				if (data.state == '1') {
					createState(data.result, function(){
						location.href='register3.html';
					});
					//var user = data.user;
					//localStorage.setItem('$LOGIN_INFO',JSON.stringify(user));
				}
			},jsonToParams(param),null,function(){
				mui.toast('抱歉，当前服务不可用，请稍后再试');
			})
			
			/*var url = '_www/src/login/registSuccess.html';
			showTemplates('registSuccess.html','注册成功',url);*/
		});
		//密码检测
		function psdCheck(value){
			var score = 0;
			if(value.length > 5 && value.length < 16){
				var digit = false, alpha = false, other = false;
				//assic码：数字48-57 字母：65-90 97-122
				for(var i=0; i<value.length; i++){
					var c = value.charCodeAt(i);
					if(c>=48 && c<=57){
						digit = true;
					}else if(c>=65 && c<=90){
						alpha = true;
					}else if(c>=97 && c<=122){
						alpha = true;
					}else{
						other = true;
					}
				}
				if(digit) score++;
				if(alpha) score++;
				if(other) score++
			} else {
				mui.toast('密码为6-15位字符，必须由数字、字母或符号两种以上组成');
				return false;
			}
			if (score < 2) {
				mui.toast('密码为6-15位字符，必须由数字、字母或符号两种以上组成');
				return false;
			}
			return true;
		}
	</script>
</html>